<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<!--[if lt IE 9]>
    <script src="jquery-1.9.0.js"></script>
<![endif]-->
		<!--[if gte IE 9]><!-->
		<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
		<!--<![endif]-->
		<script type="text/javascript">
			$(document).ready(function() {
				$("button").click(function() {
					$("p").offsetParent().css("background-color", "red");
				});
			});
		</script>
	</head>

	<body>

		<button>设置背景颜色</button>
		<div style="border:1px solid black;width:70%;position:absolute;left:10px;top:50px">
			<div style="border:1px solid black;margin:50px;background-color:yellow">
				<p>点击按钮这一段的设置第一个定位的父元素的背景颜色。</p>
			</div>
		</div>

	</body>

</html>